package com.ssm.springboot.controller;

import com.ssm.springboot.pojo.DataInfo;
import com.ssm.springboot.pojo.TbPermission;
import com.ssm.springboot.service.TbPermissionService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (TbPermission)表控制层
 *
 * @author makejava
 * @since 2021-12-27 21:50:50
 */
@RestController
@RequestMapping("/tbPermission")
public class TbPermissionController {
    /**
     * 服务对象
     */
    @Resource
    private TbPermissionService tbPermissionService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("/selectOne")
    @RequiresPermissions(value = {"/tbPermission/selectOne"})
    public TbPermission selectOne(Integer id) {
        return this.tbPermissionService.queryById(id);
    }

    @RequestMapping("/findAll")
    @RequiresPermissions(value = {"/tbPermission/findAll"})
    public DataInfo findAll(@RequestParam("page") int page,@RequestParam("limit") int limit){
        return tbPermissionService.queryAllByLimit(page,limit);
    }
    @RequiresPermissions(value = {"/tbPermission/add"})
    @RequestMapping("/add")
    public DataInfo add(@RequestBody TbPermission tbPermission){
        return tbPermissionService.insert(tbPermission);
    }
    @RequiresPermissions(value = {"/tbPermission/delete"})
    @RequestMapping("/delete")
    public DataInfo delete(int id){
        return tbPermissionService.deleteById(id);
    }



}